//
//  HEIMConversationManager.m
//  HealthFamily
//
//  Created by 吴欧 on 2021/3/5.
//  Copyright © 2021 honglutec. All rights reserved.
//

#import "HEIMConversationManager.h"

@interface HEIMConversationManager ()

@property (nonatomic, strong) NSMutableDictionary *sessionDict;

@end

@implementation HEIMConversationManager

#pragma mark - LifeCycle
+(instancetype)sharedManager {
    static dispatch_once_t onceToken;
    static HEIMConversationManager *instance;
    dispatch_once(&onceToken, ^{
        instance = [[HEIMConversationManager alloc] init];
    });
    return instance;
}

- (instancetype)init {
    if (self = [super init]) {
        self.sessionDict = [NSMutableDictionary dictionary];
    }
    return self;
}

- (void)registeSession:(HEIMSession *)session {
    [self.sessionDict setValue:session forKey: session.sessionId];
}


- (HEIMSession *)sessionById:(NSString *)sessionId {
    return [self.sessionDict objectForKey:sessionId];
}

- (void)removeAllSessions {
    [self.sessionDict removeAllObjects];
}

- (void)removesessionById:(NSString *)sessionId {
    [self.sessionDict removeObjectForKey:sessionId];
}

@end
